import "../sass/cang.scss";

import { useParams, useNavigate } from "react-router-dom";
import { NavBar } from "react-vant";
import Product from "../components/Product";
import { useState, useEffect } from "react";
import axios from "axios";
import { DeleteO } from "@react-vant/icons";

function Cang() {
    let navigate = useNavigate();
    let [cangdata, setCangdata] = useState([]);
    let getcang = () => {
        axios({
            method: "get",
            url: "/findAllLike",
        })
            .then((res) => {
                console.log("收藏", res.data.result);
                setCangdata(res.data.result);
            })
            .catch((err) => {});
    };
    useEffect(() => {
        getcang();
    }, []);
    return (
        <div className="cang">
            <NavBar
                title="我的收藏"
                leftText="返回"
                onClickLeft={() => navigate(-1)}
            />
            <div className="ca-bei"> </div>
            <div className="ca-box">
                <div className="maipro">
                    {cangdata.map((item, index) => {
                        return (
                            <div
                                className="product-item"
                                onClick={() => {
                                    navigate(
                                        `/detail/${item.pid}`
                                    );
                                }}
                                key={index}
                            >
                                <Product
                                    pro={item}
                                ></Product>
                                <div className="ca-biao"></div>
                            </div>
                        );
                    })}
                </div>
            </div>
        </div>
    );
}
export default Cang;
